﻿using aier.dataaccess.dapper;
using aier.dataaccess.model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace aier.business.logic
{
  public  class ProvinceBll
    {
        public ProvinceDal provinceDal { get; set; }
        public AreaDal areaDal { get; set; }

        public CityDal cityDal { get; set; }

        /// <summary>
        /// 根据名称查省 名称为空查全部
        /// </summary>
        /// <param name="provincename">省份名称</param>
        /// <returns></returns>
        public List<ProvinceView> QueryProvinceByName(string provincename)
        {
            List<ProvinceView> provinceViews = null;
            provinceViews = provinceDal.QueryProvinceByName(provincename);
            return provinceViews;
        }
        public Guid GetProvinceIdByName(string name)
        {
            return provinceDal.GetProvinceIdByName(name);
        }

        /// <summary>
        /// 根据省市区ID查询名称
        /// </summary>
        /// <param name="provinceid"></param>
        /// <param name="cityid"></param>
        /// <param name="areaid"></param>
        /// <returns></returns>
        public string[] GetProvinceCityAreaById(string provinceid, string cityid, string areaid)
        {
            List<string> pcaNames = new List<string>(3);
            pcaNames.Add(provinceDal.GetProvinceNameById(provinceid));
            pcaNames.Add(cityDal.QueryCityNameById(Guid.Parse(cityid)));
            pcaNames.Add(areaDal.GetAreaNameById(areaid));
            return pcaNames.ToArray();
            
        }
    }
}
